{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useControlled as useControlled, unstable_useForkRef as useForkRef, unstable_useIsFocusVisible as useIsFocusVisible } from '@mui/utils';\n/**\n * The basic building block for creating custom switches.\n *\n * Demos:\n *\n * - [Switches](https://mui.com/components/switches/)\n */\nexport default function useSwitch(props) {\n  const {\n    checked: checkedProp,\n    defaultChecked,\n    disabled,\n    onBlur,\n    onChange,\n    onFocus,\n    onFocusVisible,\n    readOnly,\n    required\n  } = props;\n  const [checked, setCheckedState] = useControlled({\n    controlled: checkedProp,\n    default: Boolean(defaultChecked),\n    name: 'Switch',\n    state: 'checked'\n  });\n  const createHandleInputChange = otherProps => event => {\n    var _otherProps$onChange;\n    // Workaround for https://github.com/facebook/react/issues/9023\n    if (event.nativeEvent.defaultPrevented) {\n      return;\n    }\n    setCheckedState(event.target.checked);\n    onChange == null ? void 0 : onChange(event);\n    (_otherProps$onChange = otherProps.onChange) == null ? void 0 : _otherProps$onChange.call(otherProps, event);\n  };\n  const {\n    isFocusVisibleRef,\n    onBlur: handleBlurVisible,\n    onFocus: handleFocusVisible,\n    ref: focusVisibleRef\n  } = useIsFocusVisible();\n  const [focusVisible, setFocusVisible] = React.useState(false);\n  if (disabled && focusVisible) {\n    setFocusVisible(false);\n  }\n  React.useEffect(() => {\n    isFocusVisibleRef.current = focusVisible;\n  }, [focusVisible, isFocusVisibleRef]);\n  const inputRef = React.useRef(null);\n  const createHandleFocus = otherProps => event => {\n    var _otherProps$onFocus;\n    // Fix for https://github.com/facebook/react/issues/7769\n    if (!inputRef.current) {\n      inputRef.current = event.currentTarget;\n    }\n    handleFocusVisible(event);\n    if (isFocusVisibleRef.current === true) {\n      setFocusVisible(true);\n      onFocusVisible == null ? void 0 : onFocusVisible(event);\n    }\n    onFocus == null ? void 0 : onFocus(event);\n    (_otherProps$onFocus = otherProps.onFocus) == null ? void 0 : _otherProps$onFocus.call(otherProps, event);\n  };\n  const createHandleBlur = otherProps => event => {\n    var _otherProps$onBlur;\n    handleBlurVisible(event);\n    if (isFocusVisibleRef.current === false) {\n      setFocusVisible(false);\n    }\n    onBlur == null ? void 0 : onBlur(event);\n    (_otherProps$onBlur = otherProps.onBlur) == null ? void 0 : _otherProps$onBlur.call(otherProps, event);\n  };\n  const handleRefChange = useForkRef(focusVisibleRef, inputRef);\n  const getInputProps = function () {\n    let otherProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n    return _extends({\n      checked: checkedProp,\n      defaultChecked,\n      disabled,\n      readOnly,\n      ref: handleRefChange,\n      required,\n      type: 'checkbox'\n    }, otherProps, {\n      onChange: createHandleInputChange(otherProps),\n      onFocus: createHandleFocus(otherProps),\n      onBlur: createHandleBlur(otherProps)\n    });\n  };\n  return {\n    checked,\n    disabled: Boolean(disabled),\n    focusVisible,\n    getInputProps,\n    readOnly: Boolean(readOnly)\n  };\n}","map":{"version":3,"names":["_extends","React","unstable_useControlled","useControlled","unstable_useForkRef","useForkRef","unstable_useIsFocusVisible","useIsFocusVisible","useSwitch","props","checked","checkedProp","defaultChecked","disabled","onBlur","onChange","onFocus","onFocusVisible","readOnly","required","setCheckedState","controlled","default","Boolean","name","state","createHandleInputChange","otherProps","event","_otherProps$onChange","nativeEvent","defaultPrevented","target","call","isFocusVisibleRef","handleBlurVisible","handleFocusVisible","ref","focusVisibleRef","focusVisible","setFocusVisible","useState","useEffect","current","inputRef","useRef","createHandleFocus","_otherProps$onFocus","currentTarget","createHandleBlur","_otherProps$onBlur","handleRefChange","getInputProps","type"],"sources":["/data/messenger.client/node_modules/@mui/lab/node_modules/@mui/base/SwitchUnstyled/useSwitch.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useControlled as useControlled, unstable_useForkRef as useForkRef, unstable_useIsFocusVisible as useIsFocusVisible } from '@mui/utils';\n/**\n * The basic building block for creating custom switches.\n *\n * Demos:\n *\n * - [Switches](https://mui.com/components/switches/)\n */\nexport default function useSwitch(props) {\n  const {\n    checked: checkedProp,\n    defaultChecked,\n    disabled,\n    onBlur,\n    onChange,\n    onFocus,\n    onFocusVisible,\n    readOnly,\n    required\n  } = props;\n  const [checked, setCheckedState] = useControlled({\n    controlled: checkedProp,\n    default: Boolean(defaultChecked),\n    name: 'Switch',\n    state: 'checked'\n  });\n  const createHandleInputChange = otherProps => event => {\n    var _otherProps$onChange;\n    // Workaround for https://github.com/facebook/react/issues/9023\n    if (event.nativeEvent.defaultPrevented) {\n      return;\n    }\n    setCheckedState(event.target.checked);\n    onChange == null ? void 0 : onChange(event);\n    (_otherProps$onChange = otherProps.onChange) == null ? void 0 : _otherProps$onChange.call(otherProps, event);\n  };\n  const {\n    isFocusVisibleRef,\n    onBlur: handleBlurVisible,\n    onFocus: handleFocusVisible,\n    ref: focusVisibleRef\n  } = useIsFocusVisible();\n  const [focusVisible, setFocusVisible] = React.useState(false);\n  if (disabled && focusVisible) {\n    setFocusVisible(false);\n  }\n  React.useEffect(() => {\n    isFocusVisibleRef.current = focusVisible;\n  }, [focusVisible, isFocusVisibleRef]);\n  const inputRef = React.useRef(null);\n  const createHandleFocus = otherProps => event => {\n    var _otherProps$onFocus;\n    // Fix for https://github.com/facebook/react/issues/7769\n    if (!inputRef.current) {\n      inputRef.current = event.currentTarget;\n    }\n    handleFocusVisible(event);\n    if (isFocusVisibleRef.current === true) {\n      setFocusVisible(true);\n      onFocusVisible == null ? void 0 : onFocusVisible(event);\n    }\n    onFocus == null ? void 0 : onFocus(event);\n    (_otherProps$onFocus = otherProps.onFocus) == null ? void 0 : _otherProps$onFocus.call(otherProps, event);\n  };\n  const createHandleBlur = otherProps => event => {\n    var _otherProps$onBlur;\n    handleBlurVisible(event);\n    if (isFocusVisibleRef.current === false) {\n      setFocusVisible(false);\n    }\n    onBlur == null ? void 0 : onBlur(event);\n    (_otherProps$onBlur = otherProps.onBlur) == null ? void 0 : _otherProps$onBlur.call(otherProps, event);\n  };\n  const handleRefChange = useForkRef(focusVisibleRef, inputRef);\n  const getInputProps = (otherProps = {}) => _extends({\n    checked: checkedProp,\n    defaultChecked,\n    disabled,\n    readOnly,\n    ref: handleRefChange,\n    required,\n    type: 'checkbox'\n  }, otherProps, {\n    onChange: createHandleInputChange(otherProps),\n    onFocus: createHandleFocus(otherProps),\n    onBlur: createHandleBlur(otherProps)\n  });\n  return {\n    checked,\n    disabled: Boolean(disabled),\n    focusVisible,\n    getInputProps,\n    readOnly: Boolean(readOnly)\n  };\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,sBAAsB,IAAIC,aAAa,EAAEC,mBAAmB,IAAIC,UAAU,EAAEC,0BAA0B,IAAIC,iBAAiB,QAAQ,YAAY;AACxJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,SAAS,CAACC,KAAK,EAAE;EACvC,MAAM;IACJC,OAAO,EAAEC,WAAW;IACpBC,cAAc;IACdC,QAAQ;IACRC,MAAM;IACNC,QAAQ;IACRC,OAAO;IACPC,cAAc;IACdC,QAAQ;IACRC;EACF,CAAC,GAAGV,KAAK;EACT,MAAM,CAACC,OAAO,EAAEU,eAAe,CAAC,GAAGjB,aAAa,CAAC;IAC/CkB,UAAU,EAAEV,WAAW;IACvBW,OAAO,EAAEC,OAAO,CAACX,cAAc,CAAC;IAChCY,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAE;EACT,CAAC,CAAC;EACF,MAAMC,uBAAuB,GAAGC,UAAU,IAAIC,KAAK,IAAI;IACrD,IAAIC,oBAAoB;IACxB;IACA,IAAID,KAAK,CAACE,WAAW,CAACC,gBAAgB,EAAE;MACtC;IACF;IACAX,eAAe,CAACQ,KAAK,CAACI,MAAM,CAACtB,OAAO,CAAC;IACrCK,QAAQ,IAAI,IAAI,GAAG,KAAK,CAAC,GAAGA,QAAQ,CAACa,KAAK,CAAC;IAC3C,CAACC,oBAAoB,G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